<template>
  <div>
    <div id="centerChart1" style="width:120px;height:100px;" />
  </div>
</template>

<script>
const echarts = require('echarts')
export default {
  data() {
    return {}
  },
  mounted() {
    this.drawPie()
  },
  destroyed() {
    window.onresize = null
  },
  methods: {
    drawPie() {
      // 基于准备好的dom，初始化echarts实例
      const myChartPieLeft = echarts.init(
        document.getElementById('centerChart1')
      )
      //  ----------------------------------------------------------------
      const tips = 60
      const option = {
        title: [
          {
            text: tips * 1 + '%',
            x: 'center',
            y: 'center',
            textStyle: {
              color: '#3fc0fb',
              fontSize: 16
            }
          }
        ],
        series: [
          {
            type: 'pie',
            radius: ['75%', '80%'],
            center: ['50%', '50%'],
            hoverAnimation: false,
            color: ['#00bcd44a', 'transparent'],
            label: {
              normal: {
                show: false
              }
            },
            data: [
              {
                value: tips,
                itemStyle: {
                  normal: {
                    color: '#03a9f4',
                    shadowBlur: 10,
                    shadowColor: '#97e2f5'
                  }
                }
              },
              {
                value: 100 - tips
              }
            ]
          }
        ]
      }
      myChartPieLeft.setOption(option)
      // -----------------------------------------------------------------
      // 响应式变化
      window.addEventListener('resize', () => myChartPieLeft.resize(), false)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
